package com.zoweunion.mechanic.util.gaode;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

/**
 * 高德电子围栏工具类
 *
 * https://lbs.amap.com/api/webservice/guide/api/geofence_service#t10
 */
@Component
public class EnclosureUtil {

    private final String key = "06959c1223a9b6c69d69e65c3d7a70ce";

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 围栏设备监控
     * @param thingsId
     * @param locations
     * @return
     */
    public Map geofenceStatus(String thingsId, String locations){
        String url = "https://restapi.amap.com/v4/geofence/status?key="+ key +"&diu=867955032363126&uid=%s&locations=%s";
        url = String.format(url, thingsId, locations);
        return restTemplate.getForObject(url, Map.class);
    }
}
